/*
 * @Author: zhoulei0232
 * @Date: 2021-06-24 15:36:10
 * @LastEditTime: 2021-07-07 15:34:05
 * @LastEditors: zhoulei0232
 * @Description:
 */
import { InjectionKey } from "vue";

import { createStore, Store, useStore as baseUseStore } from "vuex";
import appModule, { AppStateTypes } from "./modules/app";
import getters from "./getters";

export interface RootStateTypes {}
interface AllStateTypes extends RootStateTypes {
  appModule: AppStateTypes;
}

export const store = createStore<RootStateTypes>({
  state: {},
  mutations: {},
  actions: {},
  modules: {
    appModule,
  },
  getters,
});

export const key: InjectionKey<Store<RootStateTypes>> = Symbol("vue-store");

export function useStore<T = AllStateTypes>() {
  return baseUseStore<T>(key);
}
